<!-- 我的银行卡 -->
<template>
	<view>
		<navbar :isFixed="true" title="我的银行卡" :borderBottom="false"></navbar>
		<view class="block"></view>
		<view class="count">共{{list.length}}张银行卡</view>
		<view class="list">
			<view class="card" v-for="(item,index) in list" :key="index">
				<view class="" style="text-align: center;"> {{item.bank_name}}</view>
				<view class="cancel" @click="cancelcard(item)">取消绑定</view>
			</view>
		</view>
		<view style="height:150rpx;"></view>
		<navigator class="btn" url="/personal/addCard" hover-class="none">添加银行卡</navigator>
	</view>
</template>

<script>
	var _this;
	import navbar from '@/uview-ui/components/u-navbar/u-navbar.vue';
	export default {
		components: {
			navbar
		},
		data() {
			return {
				list: []
			}
		},
		onLoad(options) {
			_this = this
			_this.getcard()
		},
		methods: {
			getcard() {
				_this.$api.get("getbanklist").then(data => {
					console.log(data.data)
					_this.list = data.data
				});
			},

			cancelcard(e) {
				_this.$api.post("unboundbank", {
					id: e.id
				}).then(data => {
					uni.showToast({
						title: '解绑成功',
						icon: 'success',
						duration: 2000,
						success: function() {
							setTimeout(function() {
								_this.getcard()
							}, 500);
						}
					})
				});
			},
		}
	}
</script>

<style lang="scss" scoped>
	page {
		font-family: PingFang SC;
	}

	.block {
		height: 10rpx;
		background-color: #F2F2F2;
	}

	.count {
		font-size: 28rpx;
		font-weight: 500;
		margin-left: 59rpx;
		margin-top: 35rpx;
		color: #999999;
	}

	.list {
		padding-left: 48rpx;
		margin-top: 45rpx;

		.card {
			width: 655rpx;
			height: 240rpx;
			background-color: #FBA84E;
			border-radius: 16rpx;
			position: relative;
			margin-bottom: 30rpx;

			.cancel {
				width: 655rpx;
				height: 73rpx;
				opacity: 0.5;
				background: #595959;
				border-radius: 0 0 16rpx 16rpx;
				font-size: 28rpx;
				font-weight: 500;
				text-align: center;
				line-height: 73rpx;
				color: #fffefe;
				position: absolute;
				bottom: 0;
				left: 0;
			}
		}
	}

	.btn {
		width: 680rpx;
		height: 90rpx;
		background: linear-gradient(86deg, #38be8c 0%, #05adbb 100%);
		border-radius: 45rpx;
		font-size: 34rpx;
		font-weight: 700;
		text-align: center;
		color: #ffffff;
		line-height: 90rpx;
		position: fixed;
		bottom: 61rpx;
		left: 43rpx;
	}
</style>
